$(function () {
    var vm = new Vue({
      el: "#app",
      data: {
        // 统计数据
        statistics: {
          projectSum: 0,
          totalCalls: 0,
          todaySum: 0,
          browseSum: 0,
        },
        apiUrl:  window.location.href.indexOf('127.0.0.1') > -1  ?'http://39.106.120.139':''
      },
      created: function () {
        this.getHotKey(); // 获取热词
      },
      mounted: function () {
  
      },
      computed: {
          // 分页索引
          indexs: function() {
              var _this = this;
              var left = 1; //默认起始值是1
              var right = _this.allNum; //终止值是全部
              var arr = [];
              if(this.allNum>= 5){
                  if(this.cur > 3 && this.cur < this.allNum-2){
                          left = this.cur - 2
                          right = this.cur + 2
                  }else{
                      if(this.cur<=3){
                          left = 1
                          right = 5
                      }else{
                          right = this.allNum
                          left = this.allNum -4
                      }
                  }
              }
              while (left <= right){
                  arr.push(left)
                  left ++
              }
              return arr
          }
      },
      methods: {
        getHotKey: function () {
          const _this = this;
          $.ajax({
              url:  _this.apiUrl + "/ProjectApi/Indexdata",
              // url: "http://39.106.120.139/ProjectApi/Indexdata",
            data: {},
            type: "get",
            cache: false,
            dataType: "json",
            success: function (data) {
              console.log(data.data);
              if (data.data.hotkeys) {
                  _this.hotkeys = data.data.hotkeys;
                  _this.categorys = data.data.categorys;
                  _this.statistics = data.data.statistics;
              }
            },
            error: function (e) {
              // view("异常！");
              console.log('error', e);
              // alert("异常！");
            },
          });
        },



      },
    });
  });
  